package com.device.operating.service.impl;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.device.operating.dao.GroupRepository;
import com.device.operating.entity.Grouptab;
import com.device.operating.service.GroupService;

@Service("GroupService")
@Transactional(propagation=Propagation.REQUIRED)
public class GroupServiceImpl implements GroupService{
	
	@Autowired
	private GroupRepository GroupRepository;

	@Override
	public void addgroup(Grouptab group) {
		// TODO Auto-generated method stub
		GroupRepository.save(group);
	}

	@Override
	public List<Grouptab> queryall() {
		// TODO Auto-generated method stub
		List<Grouptab> lg=new ArrayList<>();
		Iterable<Grouptab> iter=GroupRepository.findAll();
		Iterator<Grouptab> it=iter.iterator();
		while(it.hasNext()){
			lg.add(it.next());
		}
		return lg;
	}

	@Override
	public List<Grouptab> querybygpname(String gpname) {
		// TODO Auto-generated method stub
		return GroupRepository.findByGpname(gpname);
	}

	@Override
	public Grouptab queryone(String gpId) {
		// TODO Auto-generated method stub
		return GroupRepository.findOne(gpId);
	}

	@Override
	public void deletegroup(String gpId) {
		// TODO Auto-generated method stub
		GroupRepository.delete(gpId);
	}

	
}
